package com.testing.class7;

import com.sun.org.apache.bcel.internal.generic.NEW;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @Classname ExcelWriteTest
 * @Description 类型说明
 * @Date 2022/10/19 20:55
 * @Created by 特斯汀Roy
 */
public class ExcelWriteTest {
    public static void main(String[] args) throws IOException {
        //写一个新的excel文件，然后创建sheet页写一个单元格。
        //其实是在jvm里面创建一个file类型的对象。
        File newExcel=new File("Cases/newTest.xlsx");
        newExcel.createNewFile();
        Workbook newBook=new XSSFWorkbook();
        newBook.createSheet("另一个测试sheet页");
        Sheet vip13测试sheet = newBook.createSheet("VIP13测试sheet");
        Row row = vip13测试sheet.createRow(0);
        Cell cell = row.createCell(0);
        cell.setCellValue("写入了excel文件");
        System.out.println(cell);
        //创建写入文件的outputStream流
        FileOutputStream out=new FileOutputStream(newExcel);
        newBook.write(out);
        //一定记得调用close关闭输入输出流
        out.close();
        newBook.close();



    }


}
